p = input()
a = p.split()
num = ''
flag = True
for i in a:
    if i == 'zero':
        num += '0'
    elif i == 'one':
        num += '1'
    elif i == 'two':
        num += '2'
    elif i == 'three':
        num += '3'
    elif i == 'four':
        num += '4'
    elif i == 'five':
        num += '5'
    elif i == 'six':
        num += '6'
    elif i == 'seven':
        num += '7'
    elif i == 'eight':
        num += '8'
    elif i == 'nine':
        num += '9'
if len(num) != 3:
    flag = False
    print('Wrong input')
if flag:
    for j in range(1, int(num)):
        for x in range(3, j):
            if j % x == 0:
                break
        else:
            ot = j
    for j in range(int(num), int(num) + int(num) - ot):
        for x in range(3, j):
            if j % x == 0:
                break
        else:
            ot = j
    print(ot)
